package cn.study.luckyadapter.controller;

import cn.study.common.annotation.ResponseResult;
import cn.study.luckyclient.api.IActivityConfigService;
import cn.study.luckyclient.api.IActivityService;
import cn.study.luckyclient.dto.data.ActivityConfigVo;
import cn.study.luckyclient.dto.data.ActivityVo;
import cn.study.luckyclient.dto.data.DrawResultVo;
import cn.study.luckyclient.dto.query.ActivityListByParamQuery;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@ResponseResult
@AllArgsConstructor
@RequestMapping("/v1/activity")
public class ActivityController {
    private final IActivityService activityService;
    private final IActivityConfigService activityConfigService;

    @GetMapping("/page")
    public IPage<ActivityVo> page(@RequestBody ActivityListByParamQuery activityListByParamQuery) {
        return activityService.page(activityListByParamQuery);
    }
    @GetMapping("/draw")
    public DrawResultVo draw(@RequestParam("activityId") Long activityId, HttpServletRequest request) {
        String userId1=request.getHeader("id");
        Long userId=Long.parseLong(userId1);
        return activityService.draw(activityId,userId);
    }
    @GetMapping("/one")
    public ActivityConfigVo one(@RequestParam("id") Long id){
       return activityConfigService.one(id);
    }
}
